package library.gui.component;

import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;

public class ChoiceLine extends BorderPane implements TextLine {
	
	private Label label;
	private ChoiceBox<String> box;
	
	public ChoiceLine(String key, String...select) {

		this.label = new Label(key);

		this.setPadding(new Insets(0, 10, 0, 0));
		this.box = new ChoiceBox<String>(
			FXCollections.observableArrayList(select));
		
		this.setPadding(new Insets(0, 10, 0, 10));
		this.box.prefWidthProperty().bind(this.prefWidthProperty());

		this.setLeft(label);
		this.setCenter(box);
		
	}

	@Override
	public void scale(double left) {
		label.prefWidthProperty().bind(this.widthProperty().multiply(left));
		box.prefWidthProperty().bind(this.widthProperty().multiply(1-left));
	}

	@Override
	public String getValue() {
		return box.getValue();
	}

	@Override
	public void setValue(String string) {
		box.setValue(string);
	}

}
